package com.sx.pipeline.adapter

import android.annotation.SuppressLint
import android.util.Log
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.noober.background.view.BLTextView
import com.sx.pipeline.R
import com.sx.pipeline.repos.http.res.MessageListVo
import com.sx.pipeline.repos.http.res.ReleaseNeedsVO
import com.sx.pipeline.repos.http.res.ReleaseSupplyVo
import com.sx.pipeline.utils.AndroidUtil
import com.sx.pipeline.utils.CountDownUtil

/**
 * @Author：YY
 * @Date：2022/2/10
 * @Describe: 运营商我的需求列表适配器
 */
class ParticipationNeedsListAdapter
    (
    dataList: MutableList<ReleaseNeedsVO>
) : BaseQuickAdapter<ReleaseNeedsVO, BaseViewHolder>(
    R.layout.item_participation_needs,dataList
) {
    var callCallBack:((String)->Unit)?=null
    override fun convert(holder: BaseViewHolder, item: ReleaseNeedsVO) {
        //创建时间
        holder.setText(R.id.tv_time,item.createTime)
        //标题
        holder.setText(R.id.tv_title, item.needType)
        //联系人
        holder.setText(R.id.tv_contact, "联系人：${item.contact}")
        //联系方式
        holder.setText(R.id.tv_contact_num, "联系方式：${item.contactPhone}")
        //需求类型 0:Equipment、1:Unit、2:Serve
        when(item.needDownType){
            0->{
                holder.setText(R.id.tv_device_name,"设备名称：${item.omsNeedEquipment?.name}")
                holder.setText(R.id.tv_device_code,"产品编号：${item.omsNeedEquipment?.equipmentNo}")
                holder.setText(R.id.tv_car_num,"车牌号码：${item.omsNeedEquipment?.numberPlate}")

                holder.setVisible(R.id.tv_device_name,true)
                holder.setVisible(R.id.tv_device_code,true)
                holder.setVisible(R.id.tv_car_num,true)

                holder.setGone(R.id.tv_work_load,true)
                holder.setGone(R.id.tv_address,true)
            }
            1->{
                holder.setText(R.id.tv_work_load,"工作量：${item.omsNeedUnit?.quantity+item.omsNeedUnit?.unit}")
                holder.setText(R.id.tv_address,"施工地点：${item.addressDetail}")

                holder.setGone(R.id.tv_device_name,true)
                holder.setGone(R.id.tv_device_code,true)
                holder.setGone(R.id.tv_car_num,true)

                holder.setVisible(R.id.tv_work_load,true)
                holder.setVisible(R.id.tv_address,true)
            }
        }


        holder.getView<BLTextView>(R.id.tv_action).setOnClickListener {
            callCallBack?.invoke(item.contactPhone)
        }

    }
}